package io.renren.modules.testinit.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.testinit.entity.TestinitEntity;
import io.renren.modules.testinit.service.TestinitService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-08-17 18:02:45
 */
@RestController
@RequestMapping("testinit/testinit")
public class TestinitController {
    @Autowired
    private TestinitService testinitService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("testinit:testinit:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = testinitService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{userNo}")
    @RequiresPermissions("testinit:testinit:info")
    public R info(@PathVariable("userNo") Integer userNo){
		TestinitEntity testinit = testinitService.getById(userNo);

        return R.ok().put("testinit", testinit);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("testinit:testinit:save")
    public R save(@RequestBody TestinitEntity testinit){
		testinitService.save(testinit);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("testinit:testinit:update")
    public R update(@RequestBody TestinitEntity testinit){
		testinitService.updateById(testinit);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("testinit:testinit:delete")
    public R delete(@RequestBody Integer[] userNos){
		testinitService.removeByIds(Arrays.asList(userNos));

        return R.ok();
    }

}
